***********************************************Racial Identity, Reactions to Inequality, and Fairness Concepts among Americans***********************************



*This do-file includes:

*1) Data Preparation Section
*2) Analyses that are presented in the main text
*3) Analyses that are presented in the appendix 



**************************************************************************************************
*************************************************1) Data Preparation******************************
**************************************************************************************************



{
	
clear all
use "Data.dta"

*Comment on raw data set: 
*As noted in the main text, 8 subjects failed to provide a completion code on Prolific. We have no data stored for them. Thus the raw data includes 1192 subjects instead of the 1200 we ordered at Prolific. 
*The survey that is attached to the Appendix indicates which items correspond to the respective variables. 
*The variable "ShownGroups"	indicates which of the 4 sets of groups the subjects saw and towards whom the subjects could allocate money in the main money allocation decisions. The description of the design in the main text and the Appendix further ellaborate on the composition of these groups. 


************Drop subjects who failed the attention check as pre-registered

drop if Policy_pretreat_3!="Strongly agree"

************Generate treatment dummies 

gen Die=0
replace Die=1 if Treatment=="Die"

gen IngroupDecider=0
replace IngroupDecider=1 if Treatment=="Black Decider" & Race=="Black or African American"
replace IngroupDecider=1 if Treatment=="White Decider" & Race=="White"

gen OutgroupDecider=0
replace OutgroupDecider=1 if Treatment=="Black Decider" & Race=="White" 
replace OutgroupDecider=1 if Treatment=="White Decider" & Race=="Black or African American"

gen HumanDecider=0
replace HumanDecider=1 if Treatment=="Black Decider" | Treatment=="White Decider"


************Allocation decisions. "_1" at the end of a variable means that the variable captures the allocation towards the black group. "_2" at the end of a variable means that the variable captures the allocation towards the white group.  

*Amount the subjects allocate towards their ingroup if both groups got the same previously (either by a decider or by the die)
gen EqualSplit=real(DeciderEqual_1) if Race=="Black or African American"
replace EqualSplit=real(DeciderEqual_2) if Race=="White"  & missing(EqualSplit)
replace EqualSplit=real(DieEqual_1) if Race=="Black or African American" & missing(EqualSplit)
replace EqualSplit=real(DieEqual_2) if Race=="White" & missing(EqualSplit)

*Amount the subjects allocate towards their ingroup if the ingroup got less previously (either by a decider or by the die)
gen IGGetsLess=real(DeciderWhiteMore_1) if Race=="Black or African American" 
replace IGGetsLess=real(DeciderBlackMore_2) if Race=="White"  & missing(IGGetsLess)
replace IGGetsLess=real(DieWhiteMore_1) if Race=="Black or African American"  & missing(IGGetsLess)
replace IGGetsLess=real(DieBlackMore_2) if Race=="White" & missing(IGGetsLess)

*Amount the subjects allocate towards their ingroup if the ingroup got more previously (either by a decider or by the die)
gen IGGetsMore=real(DeciderBlackMore_1) if Race=="Black or African American" 
replace IGGetsMore=real(DeciderWhiteMore_2) if Race=="White" & missing(IGGetsMore)
replace IGGetsMore=real(DieBlackMore_1) if Race=="Black or African American"  & missing(IGGetsMore)
replace IGGetsMore=real(DieWhiteMore_2) if Race=="White" & missing(IGGetsMore)

*Compensations
gen CompensationIG=IGGetsLess-50
gen CompensationOG=50-IGGetsMore

**********Fairness concepts

***IGGetsLess condition

*Dummy that equals 1 if the subject allocates more than 80 Tokens to their ingroup in the IGGetsLess condition
gen OverReduceIneqIGGetsLess=0
replace OverReduceIneqIGGetsLess=1 if IGGetsLess>80

*Dummy that equals 1 if the subject allocates 80 Tokens to their ingroup in the IGGetsLess condition
gen ReduceIneqIGGetsLess=0
replace ReduceIneqIGGetsLess=1 if IGGetsLess==80

*Dummy that equals 1 if the subject allocates between 50 and 80 Tokens to their ingroup in the IGGetsLess condition
gen PartReduceIneqIGGetsLess=0
replace PartReduceIneqIGGetsLess=1 if IGGetsLess>50 & IGGetsLess<80

*Dummy that equals 1 if the subject allocates 50 Tokens to their ingroup in the IGGetsLess condition
gen IgnoreIneqIGGetsLess=0
replace IgnoreIneqIGGetsLess=1 if IGGetsLess==50

*Dummy that equals 1 if the subject allocates less than 50 Tokens to their ingroup in the IGGetsLess condition
gen ExcacerbateIneqIGGetsLess=0
replace ExcacerbateIneqIGGetsLess=1 if IGGetsLess<50

***IGGetsMore condition

*Dummy that equals 1 if the subject allocates less than 20 Tokens to their ingroup in the IGGetsMore condition
gen OverReduceIneqIGGetsMore=0
replace OverReduceIneqIGGetsMore=1 if IGGetsMore<20

*Dummy that equals 1 if the subject allocates 20 Tokens to their ingroup in the IGGetsMore condition
gen ReduceIneqIGGetsMore=0
replace ReduceIneqIGGetsMore=1 if IGGetsMore==20

*Dummy that equals 1 if the subject allocates between 20 and 50 Tokens to their ingroup in the IGGestMore condition
gen PartReduceIneqIGGetsMore=0
replace PartReduceIneqIGGetsMore=1 if IGGetsMore<50 & IGGetsMore>20

*Dummy that equals 1 if the subject allocates 50 Tokens to their ingroup in the IGGetsMore condition
gen IgnoreIneqIGGetsMore=0
replace IgnoreIneqIGGetsMore=1 if IGGetsMore==50

*Dummy that equals 1 if the subject allocates more than 50 Tokens to their ingroup in the IGGetsMore condition
gen ExcacerbateIneqIGGetsMore=0
replace ExcacerbateIneqIGGetsMore=1 if IGGetsMore>50

***Generating "Type" variable

*Variable that denotes which of the above coded 5 distinct behavioral responses the subject chooses in the IGGetsLess condition
gen TypeIGGetsLess=.
replace TypeIGGetsLess=1 if OverReduceIneqIGGetsLess==1
replace TypeIGGetsLess=2 if ReduceIneqIGGetsLess==1
replace TypeIGGetsLess=3 if PartReduceIneqIGGetsLess==1
replace TypeIGGetsLess=4 if IgnoreIneqIGGetsLess==1
replace TypeIGGetsLess=5 if ExcacerbateIneqIGGetsLess==1

*Variable that denotes which of the above coded 5 distinct behavioral responses the subject chooses in the IGGetsMore condition
gen TypeIGGetsMore=.
replace TypeIGGetsMore=1 if OverReduceIneqIGGetsMore==1
replace TypeIGGetsMore=2 if ReduceIneqIGGetsMore==1
replace TypeIGGetsMore=3 if PartReduceIneqIGGetsMore==1
replace TypeIGGetsMore=4 if IgnoreIneqIGGetsMore==1
replace TypeIGGetsMore=5 if ExcacerbateIneqIGGetsMore==1

***Generating simpler "Type" variables

gen EqualSplitTypeSimple=2
replace EqualSplitTypeSimple=1 if EqualSplit<=49
replace EqualSplitTypeSimple=3 if EqualSplit>=51
gen IGGetsLessTypeSimple=2
replace IGGetsLessTypeSimple=1 if IGGetsLess<=49
replace IGGetsLessTypeSimple=3 if IGGetsLess>=51
gen IGGetsMoreTypeSimple=2
replace IGGetsMoreTypeSimple=1 if IGGetsMore<=49
replace IGGetsMoreTypeSimple=3 if IGGetsMore>=51

***Switching between fairness concepts

gen Switching=1
replace Switching=0 if (OverReduceIneqIGGetsLess==1 & OverReduceIneqIGGetsMore==1) | (ReduceIneqIGGetsLess==1 & ReduceIneqIGGetsMore==1) | (PartReduceIneqIGGetsLess==1 & PartReduceIneqIGGetsMore==1) | (IgnoreIneqIGGetsLess==1 & IgnoreIneqIGGetsMore==1) | (ExcacerbateIneqIGGetsLess==1 & ExcacerbateIneqIGGetsMore==1)

gen SwitchingFavorsIG=0
replace SwitchingFavorsIG=1 if ReduceIneqIGGetsMore==1 & OverReduceIneqIGGetsLess==1 
replace SwitchingFavorsIG=1 if PartReduceIneqIGGetsMore==1 & (OverReduceIneqIGGetsLess==1 | ReduceIneqIGGetsLess==1)
replace SwitchingFavorsIG=1 if IgnoreIneqIGGetsMore==1 & (OverReduceIneqIGGetsLess==1 | ReduceIneqIGGetsLess==1 | PartReduceIneqIGGetsLess==1)
replace SwitchingFavorsIG=1 if ExcacerbateIneqIGGetsMore==1 & (OverReduceIneqIGGetsLess==1 | ReduceIneqIGGetsLess==1 | PartReduceIneqIGGetsLess==1 | IgnoreIneqIGGetsLess)

gen SwitchingFavorsOG=0
replace SwitchingFavorsOG=1 if Switching==1 & SwitchingFavorsIG==0

gen SameFairnessConcept=0
replace SameFairnessConcept=1 if Switching==0

gen SwitchType=.
replace SwitchType=1 if SwitchingFavorsIG==1
replace SwitchType=2 if SwitchingFavorsIG==0 & Switching==1
replace SwitchType=3 if Switching==0 

***********Demographics

gen White=0
replace White=1 if Race=="White"

gen Republican=0
replace Republican=1 if PartyPreference=="Republican Party"

gen Democrat=0
replace Democrat=1 if PartyPreference=="Democratic Party"

gen CollegeDegree=0
replace CollegeDegree=1 if Education=="Bachelor's degree" | Education=="Master's degree" | Education=="More than master's degree" 

gen age=real(Age)
encode Gender, gen(gender)
encode Education, gen(education)
encode Income, gen(income)
encode PartyPreference, gen(party)

***********WTPs. Code dummies that denote whether or not the subject pays 10 Tokens to implement their favored split in the three within-subject conditions

gen WTPEqualSplit=0
replace WTPEqualSplit=1 if WTPDeciderEqual=="Yes, I want to pay 10 Tokens to implement my preferred split."
replace WTPEqualSplit=1 if WTPDieEqual=="Yes, I want to pay 10 Tokens to implement my preferred split."

gen WTPIGGetsLess=0
replace WTPIGGetsLess=1 if WTPDeciderBlackMore=="Yes, I want to pay 10 Tokens to implement my preferred split." & White==1
replace WTPIGGetsLess=1 if WTPDeciderWhiteMore=="Yes, I want to pay 10 Tokens to implement my preferred split." & White==0
replace WTPIGGetsLess=1 if WTPDieBlackMore=="Yes, I want to pay 10 Tokens to implement my preferred split." & White==1
replace WTPIGGetsLess=1 if WTPDieWhiteMore=="Yes, I want to pay 10 Tokens to implement my preferred split." & White==0

gen WTPIGGetsMore=0
replace WTPIGGetsMore=1 if WTPDeciderBlackMore=="Yes, I want to pay 10 Tokens to implement my preferred split." & White==0
replace WTPIGGetsMore=1 if WTPDeciderWhiteMore=="Yes, I want to pay 10 Tokens to implement my preferred split." & White==1
replace WTPIGGetsMore=1 if WTPDieBlackMore=="Yes, I want to pay 10 Tokens to implement my preferred split." & White==0
replace WTPIGGetsMore=1 if WTPDieWhiteMore=="Yes, I want to pay 10 Tokens to implement my preferred split." & White==1

***********Closeness results (IOS scale)

*Closeness with Democrat
gen IOSDem=1 if ClosenessDemocrat=="1 - Not close at all"
replace IOSDem=2 if ClosenessDemocrat=="2"
replace IOSDem=3 if ClosenessDemocrat=="3"
replace IOSDem=4 if ClosenessDemocrat=="4"
replace IOSDem=5 if ClosenessDemocrat=="5"
replace IOSDem=6 if ClosenessDemocrat=="6"
replace IOSDem=7 if ClosenessDemocrat=="7 - Very close"

*Closeness with Republican
gen IOSRep=1 if ClosenessRepublican=="1 - Not close at all"
replace IOSRep=2 if ClosenessRepublican=="2"
replace IOSRep=3 if ClosenessRepublican=="3"
replace IOSRep=4 if ClosenessRepublican=="4"
replace IOSRep=5 if ClosenessRepublican=="5"
replace IOSRep=6 if ClosenessRepublican=="6"
replace IOSRep=7 if ClosenessRepublican=="7 - Very close"

*Closeness with White person
gen IOSWhite=1 if ClosenessWhite=="1 - Not close at all"
replace IOSWhite=2 if ClosenessWhite=="2"
replace IOSWhite=3 if ClosenessWhite=="3"
replace IOSWhite=4 if ClosenessWhite=="4"
replace IOSWhite=5 if ClosenessWhite=="5"
replace IOSWhite=6 if ClosenessWhite=="6"
replace IOSWhite=7 if ClosenessWhite=="7 - Very close"

*Closeness with Black person
gen IOSBlack=1 if ClosenessBlack=="1 - Not close at all"
replace IOSBlack=2 if ClosenessBlack=="2"
replace IOSBlack=3 if ClosenessBlack=="3"
replace IOSBlack=4 if ClosenessBlack=="4"
replace IOSBlack=5 if ClosenessBlack=="5"
replace IOSBlack=6 if ClosenessBlack=="6"
replace IOSBlack=7 if ClosenessBlack=="7 - Very close"

*Absolute difference between closeness to Whites and closeness to Blacks
gen AbsIOSDiffWB=abs(IOSWhite-IOSBlack)

*Coding closeness to whites and blacks in terms of ingroup and outgroup
gen IOSIG=IOSWhite if White==1
replace IOSIG=IOSBlack if White==0
gen IOSOG=IOSWhite if White==0
replace IOSOG=IOSBlack if White==1

***********Norms

gen Norm1=.
replace Norm1=1 if Norms_1=="Strongly disagree"
replace Norm1=2 if Norms_1=="Somewhat disagree"
replace Norm1=3 if Norms_1=="Neither agree nor disagree"
replace Norm1=4 if Norms_1=="Somewhat agree"
replace Norm1=5 if Norms_1=="Strongly agree"

gen Norm2=.
replace Norm2=1 if Norms_2=="Strongly disagree"
replace Norm2=2 if Norms_2=="Somewhat disagree"
replace Norm2=3 if Norms_2=="Neither agree nor disagree"
replace Norm2=4 if Norms_2=="Somewhat agree"
replace Norm2=5 if Norms_2=="Strongly agree"

gen Norm3=.
replace Norm3=1 if Norms_3=="Strongly disagree"
replace Norm3=2 if Norms_3=="Somewhat disagree"
replace Norm3=3 if Norms_3=="Neither agree nor disagree"
replace Norm3=4 if Norms_3=="Somewhat agree"
replace Norm3=5 if Norms_3=="Strongly agree"

*Absolute differences in agreement with norm 2 and norm 3
gen AbsDifferenceNorms=abs(Norm3-Norm2)

save "DataCleaned", replace

}





**************************************************************************************************
**************************************************2) Analysis Main Text***************************
**************************************************************************************************

*Open cleaned data
clear all
use "DataCleaned.dta"


**************Section 4: Data

{



***Power calculations

{

***Power H1 (comparison EqualSplit vs IGGetsLess)

{
	
*calculate relevant parameters
clear all
use "DataCleaned.dta"
gen IGGetsLess5050=0
replace IGGetsLess5050=1 if IGGetsLess==50
gen EqualSplit5050=0
replace EqualSplit5050=1 if EqualSplit==50
tab IGGetsLess5050
tab EqualSplit5050

*simulate power 
clear all
set seed 9999
program define sim_reg, rclass
    version 17
    syntax
    preserve
    drop _all
    set obs 1133

    * Generate data
	gen IGGetsLess5050=runiform() < 0.3327
	gen EqualSplit5050=runiform() < 0.8738

	*run test 
	quietly 	
	ttest EqualSplit5050==IGGetsLess5050
	return scalar pval = r(p_u) 
	*return list

    restore
end

* Run 500 simulations
simulate pval=r(pval), reps(500): sim_reg

* Compute power
gen sig = pval < 0.05
summarize sig

}

***Power H1 (comparison EqualSplit vs IGGetsMore)

{
	
*calculate relevant parameters
clear all
use "DataCleaned.dta"
gen IGGetsMore5050=0
replace IGGetsMore5050=1 if IGGetsMore==50
gen EqualSplit5050=0
replace EqualSplit5050=1 if EqualSplit==50
tab IGGetsMore5050
tab EqualSplit5050

*simulate power 
clear all
set seed 9999
program define sim_reg, rclass
    version 17
    syntax
    preserve
    drop _all
    set obs 1133

    * Generate data
	gen IGGetsMore5050=runiform() < 0.3672
	gen EqualSplit5050=runiform() < 0.8738

	*run test 
	quietly 	
	ttest EqualSplit5050==IGGetsMore5050
	return scalar pval = r(p_u) 
	*return list

    restore
end

* Run 500 simulations
simulate pval=r(pval), reps(500): sim_reg

* Compute power
gen sig = pval < 0.05
summarize sig

}

***Power H2 

{
	
*calculate relevant parameters
clear all
use "DataCleaned.dta"
sum EqualSplit
sum IGGetsLess



*simulate power 
clear all
set seed 9999
program define sim_reg, rclass
    version 17
    syntax
    preserve
    drop _all
    set obs 1133

    * Generate data
	gen IGGetsLess=61.86022 + 100*rnormal(0,.1896584)
	replace IGGetsLess=0 if IGGetsLess<=0
	replace IGGetsLess=100 if IGGetsLess>=100
	gen EqualSplit= 51.8173 + 100*rnormal(0, 0.09957559)
	replace EqualSplit=0 if EqualSplit<=0
	replace EqualSplit=100 if EqualSplit>=100

	*run test 
	quietly 	
	ttest EqualSplit==IGGetsLess
	return scalar pval = r(p_l) 
	*return list

    restore
end

* Run 500 simulations
simulate pval=r(pval), reps(500): sim_reg

* Compute power
gen sig = pval < 0.05
summarize sig

}


***Power H3 

{
	


	
*calculate relevant parameters
clear all
use "DataCleaned.dta"
gen IGGetsLessCostly=.
replace IGGetsLessCostly=IGGetsLess if WTPIGGetsLess==1
replace IGGetsLessCostly=50 if WTPIGGetsLess==0
sum IGGetsLessCostly
sum IGGetsLess



*simulate power 
clear all
set seed 9999
program define sim_reg, rclass
    version 17
    syntax
    preserve
    drop _all
    set obs 1133

    * Generate data
	gen IGGetsLess=61.86022 + 100*rnormal(0,.1896584)
	replace IGGetsLess=0 if IGGetsLess<=0
	replace IGGetsLess=100 if IGGetsLess>=100
	gen IGGetsLessCostly= 57.55605 + 100*rnormal(0,.1505865)
	replace IGGetsLessCostly=0 if IGGetsLessCostly<=0
	replace IGGetsLessCostly=100 if IGGetsLessCostly>=100

	*run test 
	quietly 	
	ttest IGGetsLess==IGGetsLessCostly
	return scalar pval = r(p_u) 
	*return list

    restore
end

* Run 500 simulations
simulate pval=r(pval), reps(500): sim_reg

* Compute power
gen sig = pval < 0.05
summarize sig

}

***Power H4 - not included because H4 was not supported by our data 


***Power H5

{
	
*calculate relevant parameters
clear all
use "DataCleaned.dta"
sum IGGetsLess if White==0 & HumanDecider==0
sum IGGetsLess if White==0 & HumanDecider==1
sum IGGetsLess if White==1 & HumanDecider==0
sum IGGetsLess if White==1 & HumanDecider==1
sum IGGetsLess

*simulate power 
clear all
set seed 9999
program define sim_reg, rclass
    version 17
    syntax
    preserve
    drop _all
    set obs 1133

    * Generate data
    gen Number = _n
	gen White=0
	replace White=1 if Number<=566
	gen HumanDecider=runiform() < 0.6666
	gen Interaction=0
	replace Interaction=1 if White==1 & HumanDecider==1
	gen IGGetsLess=.
	replace IGGetsLess= 61.86022 + 100*rnormal(0,.1896584) if White==0 & HumanDecider==0
	replace IGGetsLess= 66.52231 + 100*rnormal(0,.1896584) if White==0 & HumanDecider==1
	replace IGGetsLess= 68.1383 + 100*rnormal(0,.1896584) if White==1 & HumanDecider==0
	replace IGGetsLess= 66.49471 + 100*rnormal(0,.1896584) if White==1 & HumanDecider==1
	replace IGGetsLess=0 if IGGetsLess<=0
	replace IGGetsLess=100 if IGGetsLess>=100
	
	*run regression 
	quietly 	
	reg IGGetsLess HumanDecider White Interaction, r
	test Interaction
	return scalar pval = r(p)
	*return list

    restore
end

* Run 500 simulations
simulate pval=r(pval), reps(500): sim_reg

* Compute power
gen sig = pval < 0.05
summarize sig

}

clear all
use "DataCleaned.dta"


}


***Demographics 

tab Race
	
mean age if White==1
mean age if White==0

tab CollegeDegree if White==1
tab CollegeDegree if White==0

tab gender if White==1
tab gender if White==0

tab party if White==1
tab party if White==0

tab income if White==1
tab income if White==0

}


**************Section 5.1: Allocation Decisions


{
	
***Figure 2
rename EqualSplit Allocation1
rename IGGetsLess Allocation2
rename IGGetsMore Allocation3
gen ID=_n
reshape long Allocation, i(ID) j(Treat)
label define treatmentlabel 1 "EqualSplit" 2 "IGGetsLess" 3 "IGGetsMore"
label values Treat treatmentlabel
gen v2=1
cibar Allocation, over(v2 Treat)
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Allocation 
gr_edit .style.editstyle boxstyle(shadestyle(color(white))) editcopy
gr_edit .yaxis1.reset_rule 0 80 10 , tickset(major) ruletype(range)
*add gridline manually
graph export "Figure2.pdf", as(pdf) name("Graph") replace
clear all
use "DataCleaned.dta"

*T-test for Ingroup bias in "EqualSplit" condition
ttest EqualSplit==50


*Testing H1
gen EqualSplit5050=0
replace EqualSplit5050=1 if EqualSplit==50
gen IGGetsLess5050=0
replace IGGetsLess5050=1 if IGGetsLess==50
gen IGGetsMore5050=0
replace IGGetsMore5050=1 if IGGetsMore==50
ttest EqualSplit5050==IGGetsLess5050
ttest EqualSplit5050==IGGetsMore5050

*Testing H2
ttest EqualSplit==IGGetsLess

*Comparing compensation in IGGetsLess condition and IGGetsMore condition
gen IGGetsMoreReverse=100-IGGetsMore
ttest IGGetsLess=IGGetsMoreReverse


***Figure 3
rename EqualSplit Allocation1
rename IGGetsLess Allocation2
rename IGGetsMore Allocation3
gen ID=_n
reshape long Allocation, i(ID) j(Treat)
label define treatmentlabel 1 "EqualSplit" 2 "IGGetsLess" 3 "IGGetsMore"
label values Treat treatmentlabel
label define white 0 "Black subjects" 1 "White subjects"
label values White white
cibar Allocation, over(White Treat)
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Allocation 
gr_edit .style.editstyle boxstyle(shadestyle(color(white))) editcopy
gr_edit .yaxis1.reset_rule 0 80 10 , tickset(major) ruletype(range)
*add gridline manually
graph export "Figure3.pdf", as(pdf) name("Graph") replace
clear all
use "DataCleaned.dta"


***Table 1
rename education edu
local control1 age i.edu i.gender 
eststo: reg EqualSplit White, r
eststo: reg EqualSplit White `control1', r
eststo: reg IGGetsLess  White, r
eststo: reg IGGetsLess White `control1', r
eststo: reg IGGetsMore White, r
eststo: reg IGGetsMore White `control1', r
esttab using Table1.tex, p star(* 0.1 ** 0.05 *** 0.01)  r2 replace indicate("Controls= `=ustrregexra("`control1'", "i.", "*.",.)'")
est clear	
rename edu education


***Figure 4
rename EqualSplit Allocation1
rename IGGetsLess Allocation2
rename IGGetsMore Allocation3
gen ID=_n
reshape long Allocation, i(ID) j(Treat)
label define treatmentlabel 1 "EqualSplit" 2 "IGGetsLess" 3 "IGGetsMore"
label values Treat treatmentlabel
label define white 0 "Black subjects" 1 "White subjects"
label values White white
*generate treatment indicator for human vs die graph
gen Treat6=1 if Die!=1 & Treat==1  
replace Treat6=2 if Die==1 & Treat==1  
replace Treat6=3 if Die!=1 & Treat==2  
replace Treat6=4 if Die==1 & Treat==2  
replace Treat6=5 if Die!=1 & Treat==3  
replace Treat6=6 if Die==1 & Treat==3  
label define treatmentlabel6 1 "HumanEqualSplit" 2 "DieEqualSplit"  3 "HumanIGGetsLess" 4 "DieIGGetsLess" 5 "HumanIGGetsMore" 6 "DieIGGetsMore" 
label values Treat6 treatmentlabel6
cibar Allocation, over(White Treat6)
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Allocation 
gr_edit .style.editstyle boxstyle(shadestyle(color(white))) editcopy
gr_edit .yaxis1.reset_rule 0 80 10 , tickset(major) ruletype(range)
gr_edit .xaxis1.style.editstyle majorstyle(alternate(yes)) editcopy
*add gridline manually
graph export "Figure4.pdf", as(pdf) name("Graph") replace
clear all
use "DataCleaned.dta"


}


**************Section 5.2: Identity and Fairness


{

***Table 2
label define typelabel 1 "Overcompensating Inequality" 2 "Fully Compensating Inequality" 3 "Partially Compensating Inequality" 4 "Equal Treatment" 5 "Exacerbating Inequality"
label values TypeIGGetsLess  typelabel
label values TypeIGGetsMore  typelabel
estpost tab TypeIGGetsLess
est store var1_dist
estpost tab TypeIGGetsMore
est store var2_dist
esttab var1_dist var2_dist using Table2.tex,  replace cells("pct(fmt(1))")  collabels(none) unstack  noobs nonumbers varlabels(`e(labels)') mtitles("IGGetsLess" "IGGetsMore")
est clear
clear all
use "DataCleaned.dta"

***Comparing shares of distinct behavioral responses to inequality in IGGetsLess and IGGetsMore condictions
ttest OverReduceIneqIGGetsLess==OverReduceIneqIGGetsMore
ttest ReduceIneqIGGetsLess==ReduceIneqIGGetsMore
ttest PartReduceIneqIGGetsLess==PartReduceIneqIGGetsMore
ttest IgnoreIneqIGGetsLess==IgnoreIneqIGGetsMore
ttest ExcacerbateIneqIGGetsLess==ExcacerbateIneqIGGetsMore


***Table 3
label define Slabel 1 "Normative switch in favor of ingroup" 2 "Normative switch in favor of outgroup" 3 "Do not switch (color-blind)"
label values SwitchType  Slabel
estpost tab SwitchType
est store var1_dist
estpost tab SwitchType if White==0
est store var2_dist
estpost tab SwitchType if White==1
est store var3_dist
esttab var1_dist var2_dist var3_dist using Table3.tex,  replace cells("pct(fmt(1))")  collabels(none) unstack  noobs nonumbers varlabels(`e(labels)') mtitles("Full sample" "Black subjects" "White subjects")
est clear
clear all
use "DataCleaned.dta"


***Testing whether more subjects switch between fairness concepts in favor of their ingroup rather than in favor of their outgroup
ttest SwitchingFavorsIG=SwitchingFavorsOG
ttest SwitchingFavorsIG=SwitchingFavorsOG if White==0
ttest SwitchingFavorsIG=SwitchingFavorsOG if White==1

***Testing whether normative switching is more common among one racial group 
ttest SwitchingFavorsIG, by(White) welch
ttest SwitchingFavorsOG, by(White) welch
ttest SameFairnessConcept, by(White) welch	

}



**************Section 5.3 WTPs 


{



***Figure 5
rename WTPEqualSplit WTPCI1
rename WTPIGGetsLess WTPCI2
rename WTPIGGetsMore WTPCI3
gen ID=_n
reshape long WTPCI, i(ID) j(Treat)
label define treatmentlabel 1 "EqualSplit" 2 "IGGetsLess" 3 "IGGetsMore"
label values Treat treatmentlabel
rename WTPCI WTP
gen v2=1
cibar WTP, over(v2 Treat)
gr_edit .legend.draw_view.setstyle, style(no)
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush WTP 
gr_edit .style.editstyle boxstyle(shadestyle(color(white))) editcopy
graph export "Figure5.pdf", as(pdf) name("Graph") replace
clear all
use "DataCleaned.dta"

***Comparing WTPs across within-subject conditions 
ttest WTPIGGetsLess==WTPEqualSplit 
ttest WTPIGGetsMore==WTPEqualSplit 
ttest WTPIGGetsMore==WTPIGGetsLess


*Testing H3
gen IGGetsLessCostly=.
replace IGGetsLessCostly=IGGetsLess if WTPIGGetsLess==1
replace IGGetsLessCostly=50 if WTPIGGetsLess==0
ttest IGGetsLess==IGGetsLessCostly



***Figure 6
rename WTPEqualSplit WTPCI1
rename WTPIGGetsLess WTPCI2
rename WTPIGGetsMore WTPCI3
gen ID=_n
reshape long WTPCI, i(ID) j(Treat)
label define treatmentlabel 1 "EqualSplit" 2 "IGGetsLess" 3 "IGGetsMore"
label values Treat treatmentlabel
rename WTPCI WTP
label define whitelabel 0 "Black subjects" 1 "White subjects"
label values White whitelabel
cibar WTP, over(White Treat )
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush WTP 
gr_edit .style.editstyle boxstyle(shadestyle(color(white))) editcopy
graph export "Figure6.pdf", as(pdf) name("Graph") replace
clear all
use "DataCleaned.dta"

*Comparing WTPs in IGGetsLess condition and EqualSplit condition for Black and White subjects 
ttest WTPIGGetsLess==WTPEqualSplit if White==0
ttest WTPIGGetsLess==WTPEqualSplit if White==1


}



**************************************************************************************************
**************************************************3) Analyses Appendix****************************
**************************************************************************************************

************Appendix A: Procedural Information

*Tables A4 and A5: These two tables are based on the norming data. The individuals whose pictures we used gave their consent that survey participants can see their pictures. However, we did not collect their consent that we can publish how they were rated with regards to the five attributes; thus, we do not publish the norming data. Tables A4 and A5 include simple OLS regressions with robust standard errors, the respective attribute ranking as the outcome and a dummy that captures race in A4 and gender in A5. The notes under each table in the Appendix provide further information. Thus, researchers who are interested in using these norming analyses can easily run them with their own data. 


************Appendix B: Allocation Decisions 

{
	

*Table B6
rename education edu
local control1 age i.edu i.gender 
eststo: reg IGGetsLess HumanDecider, r
eststo: reg IGGetsLess HumanDecider `control1', r
eststo: reg IGGetsLess HumanDecider if  White==1, r
eststo: reg IGGetsLess HumanDecider `control1' if  White==1, r
eststo: reg IGGetsLess HumanDecider if White==0, r
eststo: reg IGGetsLess HumanDecider `control1' if White==0, r
esttab using TableB6.tex, p star(* 0.1 ** 0.05 *** 0.01)  r2 replace mtitles("Full sample" "Full sample" "White subjects" "White subjects" "Black subjects" "Black subjects")  mgroups("DV: Allocation to ingroup in case ingroup got less", pattern(1 0 0 0 0 0) span prefix(\multicolumn{@span}{c}{)suffix(}) ) indicate("Controls= `=ustrregexra("`control1'", "i.", "*.",.)'")
est clear
rename edu education 

*Table B7
rename education edu
local control1 age i.edu i.gender 
eststo: reg IGGetsMore HumanDecider, r
eststo: reg IGGetsMore HumanDecider `control1', r
eststo: reg IGGetsMore HumanDecider if  White==1, r
eststo: reg IGGetsMore HumanDecider `control1' if  White==1, r
eststo: reg IGGetsMore HumanDecider if White==0, r
eststo: reg IGGetsMore HumanDecider `control1' if White==0, r
esttab using TableB7.tex, p star(* 0.1 ** 0.05 *** 0.01)  r2 replace mtitles("Full sample" "Full sample" "White subjects" "White subjects" "Black subjects" "Black subjects")  mgroups("DV: Allocation to ingroup in case ingroup got more", pattern(1 0 0 0 0 0) span prefix(\multicolumn{@span}{c}{)suffix(}) ) indicate("Controls= `=ustrregexra("`control1'", "i.", "*.",.)'")
est clear
rename edu education 


*Table B8
rename education edu
local control1 age i.edu i.gender 
eststo: reg IGGetsLess HumanDecider##White, r
eststo: reg IGGetsLess HumanDecider##White `control1', r
esttab using TableB8.tex, varwidth(25) label nobaselevels interaction(" $\times$ ")style(tex) p star(* 0.1 ** 0.05 *** 0.01)  r2 replace indicate("Controls= `=ustrregexra("`control1'", "i.", "*.",.)'")
est clear
rename edu education  


*Table B9
rename education edu
local control1 age i.edu i.gender 
eststo: reg EqualSplit OutgroupDecider if Die==0 & White==0, r
eststo: reg EqualSplit OutgroupDecider `control1' if Die==0 & White==0, r
eststo: reg IGGetsLess OutgroupDecider if Die==0 & White==0, r
eststo: reg IGGetsLess OutgroupDecider `control1' if Die==0 & White==0, r
eststo: reg IGGetsMore OutgroupDecider if Die==0 & White==0, r
eststo: reg IGGetsMore OutgroupDecider `control1' if Die==0 & White==0, r
esttab using TableB9.tex, p star(* 0.1 ** 0.05 *** 0.01)  r2 replace indicate("Controls= `=ustrregexra("`control1'", "i.", "*.",.)'")
est clear
rename edu education 


*Table B10
rename education edu
local control1 age i.edu i.gender 
eststo: reg EqualSplit OutgroupDecider if Die==0 & White==1, r
eststo: reg EqualSplit OutgroupDecider `control1' if Die==0 & White==1, r
eststo: reg IGGetsLess OutgroupDecider if Die==0 & White==1, r
eststo: reg IGGetsLess OutgroupDecider `control1' if Die==0 & White==1, r
eststo: reg IGGetsMore OutgroupDecider if Die==0 & White==1, r
eststo: reg IGGetsMore OutgroupDecider `control1' if Die==0 & White==1, r
esttab using TableB10.tex, p star(* 0.1 ** 0.05 *** 0.01)  r2 replace indicate("Controls= `=ustrregexra("`control1'", "i.", "*.",.)'")
est clear
rename edu education  


*Table B11
rename education edu
local control1 age i.edu i.gender 
eststo: reg EqualSplit OutgroupDecider##White if Die==0, r
eststo: reg EqualSplit OutgroupDecider##White `control1' if Die==0, r
eststo: reg IGGetsLess OutgroupDecider##White if Die==0, r
eststo: reg IGGetsLess OutgroupDecider##White `control1' if Die==0, r
eststo: reg IGGetsMore OutgroupDecider##White if Die==0, r
eststo: reg IGGetsMore OutgroupDecider##White `control1' if Die==0, r
esttab using TableB11.tex, varwidth(25) label nobaselevels interaction(" $\times$ ")style(tex) p star(* 0.1 ** 0.05 *** 0.01)  stats(N r2 r2_a) replace indicate("Controls= `=ustrregexra("`control1'", "i.", "*.",.)'")
est clear
rename edu education 


*Figure B1
rename EqualSplit Allocation1
rename IGGetsLess Allocation2
rename IGGetsMore Allocation3
gen ID=_n
reshape long Allocation, i(ID) j(Treat)
*generate 3x3 treatment indicator 
gen Treat9=1 if OutgroupDecider==1 & Treat==1
replace Treat9=2 if IngroupDecider==1 & Treat==1
replace Treat9=3 if Die==1 & Treat==1
replace Treat9=4 if OutgroupDecider==1 & Treat==2
replace Treat9=5 if IngroupDecider==1 & Treat==2
replace Treat9=6 if Die==1 & Treat==2
replace Treat9=7 if OutgroupDecider==1 & Treat==3
replace Treat9=8 if IngroupDecider==1 & Treat==3
replace Treat9=9 if Die==1 & Treat==3
label define treatmentlabel9 1 "EqualSplitByOG" 2 "EqualSplitByIG" 3 "EqualSplitByDie" 4 "IGGetsLessByOG" 5 "IGGetsLessByIG" 6 "IGGetsLessByDie" 7 "IGGetsMoreByOG" 8 "IGGetsMoreByIG" 9 "IGGetsMoreByDie"
label values Treat9 treatmentlabel9
label define white 0 "Black subjects" 1 "White subjects"
label values White white
cibar Allocation, over(White Treat9)  blorientation(vertical)
gr_edit .yaxis1.title.text = {}
gr_edit .yaxis1.title.text.Arrpush Allocation 
gr_edit .style.editstyle boxstyle(shadestyle(color(white))) editcopy
gr_edit .yaxis1.reset_rule 0 80 10 , tickset(major) ruletype(range)
gr_edit .xaxis1.style.editstyle majorstyle(tickangle(vertical)) editcopy
*add gridline manually
graph export "FigureB1.pdf", as(pdf) name("Graph") replace
clear all
use "DataCleaned.dta"


}


************Appendix C: Identity and Fairness

{

***Evidence on social norms 
ttest Norm2==Norm3 if White==0
ttest Norm2==Norm3 if White==1


***Evidence on closeness perceptions measured by the IOS scale 
*Closeness to ingroup by race
ttest IOSIG, by(White) welch
*Closeness to outgroup by race
ttest IOSOG, by(White) welch


***Table C.12
label define typelabel 1 "Overcompensating Inequality" 2 "Fully Compensating Inequality" 3 "Partially Compensating Inequality" 4 "Equal Treatment" 5 "Exacerbating Inequality"
label values TypeIGGetsLess  typelabel
label values TypeIGGetsMore  typelabel
estpost tab TypeIGGetsLess if White==0
est store var1_dist
estpost tab TypeIGGetsMore if White==0
est store var2_dist
estpost tab TypeIGGetsLess if White==1
est store var3_dist
estpost tab TypeIGGetsMore if White==1
est store var4_dist
esttab var1_dist var2_dist var3_dist var4_dist using TableC12.tex,  replace cells("pct(fmt(1))")  collabels(none) unstack  noobs nonumbers varlabels(`e(labels)') mtitles("IGGetsLess" "IGGetsMore" "IGGetsLess" "IGGetsMore") mgroups("Black subjects" "White subjects", pattern(1 0 1 0) span prefix(\multicolumn{@span}{c}{)suffix(}) )
est clear
clear all
use "DataCleaned.dta"

	
*Figure C2
histogram EqualSplit, percent
gr_edit .style.editstyle boxstyle(shadestyle(color(white))) editcopy
graph export "FigureC2.pdf", as(pdf) name("Graph") replace

*Figure C3
histogram IGGetsLess, percent
gr_edit .style.editstyle boxstyle(shadestyle(color(white))) editcopy
graph export "FigureC3.pdf", as(pdf) name("Graph") replace

*Figure C4
histogram IGGetsMore, percent
gr_edit .style.editstyle boxstyle(shadestyle(color(white))) editcopy
graph export "FigureC4.pdf", as(pdf) name("Graph") replace


}


************Appendix D: WTPs

{
	
*Table D13
rename education edu
local control1 age i.edu i.gender 
eststo: reg WTPEqualSplit White, r
eststo: reg WTPEqualSplit White `control1', r
eststo: reg WTPIGGetsLess White, r
eststo: reg WTPIGGetsLess White `control1', r
eststo: reg WTPIGGetsMore White, r
eststo: reg WTPIGGetsMore White `control1', r
esttab using TableD13.tex, p star(* 0.1 ** 0.05 *** 0.01)  r2 replace  indicate("Controls= `=ustrregexra("`control1'", "i.", "*.",.)'")
est clear
rename edu education



***Table D.14
label define Typelabel 1 "More to OG" 2 "50/50" 3 "More to IG"
label values EqualSplitTypeSimple  Typelabel
label define Rlabel 0 "Black subjects" 1 "White subjects" 
label values White Rlabel
estpost tab White EqualSplitTypeSimple ,  label 
esttab using TableD14a.tex, replace cells("b(fmt(0)) rowpct(fmt(1))") unstack label varlabels(`e(labels)') nonumbers collabels("Frequency" "Percent") noobs
est clear
clear all
use "DataCleaned.dta"

label define Typelabel 1 "More to OG" 2 "50/50" 3 "More to IG"
label values EqualSplitTypeSimple  Typelabel
label define Rlabel 0 "Black subjects" 1 "White subjects" 
label values White Rlabel
estpost tab White EqualSplitTypeSimple if WTPEqualSplit==1 ,  label 
esttab using TableD14b.tex, replace cells("b(fmt(0)) rowpct(fmt(1))") unstack label varlabels(`e(labels)') nonumbers collabels("Frequency" "Percent") noobs
est clear
clear all
use "DataCleaned.dta"

label define Typelabel 1 "More to OG" 2 "50/50" 3 "More to IG"
label values IGGetsLessTypeSimple  Typelabel
label define Rlabel 0 "Black subjects" 1 "White subjects" 
label values White Rlabel
estpost tab White IGGetsLessTypeSimple ,  label 
esttab using TableD14c.tex, replace cells("b(fmt(0)) rowpct(fmt(1))") unstack label varlabels(`e(labels)') nonumbers collabels("Frequency" "Percent") noobs
est clear
clear all
use "DataCleaned.dta"

label define Typelabel 1 "More to OG" 2 "50/50" 3 "More to IG"
label values IGGetsLessTypeSimple  Typelabel
label define Rlabel 0 "Black subjects" 1 "White subjects" 
label values White Rlabel
estpost tab White IGGetsLessTypeSimple if WTPIGGetsLess==1 ,  label 
esttab using TableD14d.tex, replace cells("b(fmt(0)) rowpct(fmt(1))") unstack label varlabels(`e(labels)') nonumbers collabels("Frequency" "Percent") noobs
est clear
clear all
use "DataCleaned.dta"

label define Typelabel 1 "More to OG" 2 "50/50" 3 "More to IG"
label values IGGetsMoreTypeSimple  Typelabel
label define Rlabel 0 "Black subjects" 1 "White subjects" 
label values White Rlabel
estpost tab White IGGetsMoreTypeSimple ,  label 
esttab using TableD14e.tex, replace cells("b(fmt(0)) rowpct(fmt(1))") unstack label varlabels(`e(labels)') nonumbers collabels("Frequency" "Percent") noobs
est clear
clear all
use "DataCleaned.dta"

label define Typelabel 1 "More to OG" 2 "50/50" 3 "More to IG"
label values IGGetsMoreTypeSimple  Typelabel
label define Rlabel 0 "Black subjects" 1 "White subjects" 
label values White Rlabel
estpost tab White IGGetsMoreTypeSimple if WTPIGGetsMore==1 ,  label 
esttab using TableD14f.tex, replace cells("b(fmt(0)) rowpct(fmt(1))") unstack label varlabels(`e(labels)') nonumbers collabels("Frequency" "Percent") noobs
est clear
clear all
use "DataCleaned.dta"

*Table D15
gen CostlyCompensationIngroup=0
replace CostlyCompensationIngroup=1 if IGGetsLess>=51 & WTPIGGetsLess==1
rename education edu
local control1 age i.edu i.gender 
eststo: reg CostlyCompensationIngroup White, r
eststo: reg CostlyCompensationIngroup White `control1', r
esttab using TableD15.tex, p star(* 0.1 ** 0.05 *** 0.01)  r2 replace  mgroups("DV: Costly compensation of the ingroup", pattern(1 0) span prefix(\multicolumn{@span}{c}{)suffix(}) ) indicate("Controls= `=ustrregexra("`control1'", "i.", "*.",.)'") nomtitles
est clear
rename edu education 
clear all
use "DataCleaned.dta"

}










